# Maintainer: kpcyrd <kpcyrd[at]archlinux[dot]org>

pkgbase=espflash
pkgname=(espflash cargo-espflash)
pkgver=1.7.0
pkgrel=3
pkgdesc="Cargo subcommand for flashing Espressif devices over serial"
url='https://github.com/esp-rs/espflash'
arch=('loong64' 'x86_64')
license=('MIT' 'Apache-2.0')
depends=('libudev.so' 'libuv')
makedepends=('cargo' 'udev')
options=(!lto)
source=(https://github.com/esp-rs/${pkgbase}/archive/v${pkgver}/${pkgbase}-${pkgver}.tar.gz)
sha256sums=('3efdbcc6edeaadd4beca9c685a24486ee14729b3f638e963363328c95c89f1a3')
b2sums=('e7fb0b8abc7f0c6e0fd82b8b4b035174eb8ec56f9578d3d5b5f2477b5a1eac23cc68984f7bd147ae8e1df08b50b3de1ce055ca94f5e1b0df22b030fa5483e900')

prepare() {
  cd ${pkgbase}-${pkgver}
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd ${pkgbase}-${pkgver}
  cargo build --frozen --release
}

check() {
  cd ${pkgbase}-${pkgver}
  cargo test --frozen --workspace
}

package_espflash() {
  cd ${pkgbase}-${pkgver}
  install -Dm 755 -t "${pkgdir}/usr/bin" \
    target/release/espflash
}

package_cargo-espflash() {
  cd ${pkgbase}-${pkgver}
  install -Dm 755 -t "${pkgdir}/usr/bin" \
    target/release/cargo-espflash
}

# vim: ts=2 sw=2 et:
